<#assign title='个人信息设置'>
<#include 'header.ftl'>

<div class="layui-card">
  <div class="layui-card-body layui-row">
    <form class="layui-form" lay-filter="setting-form">
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">姓名</label>
          <div class="layui-input-block">
            <input name="name" lay-verType="tips" lay-verify="required"
                   placeholder="请输入您的名字" class="layui-input" value="${_USER.name}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">工号</label>
          <div class="layui-input-block">
            <input disabled class="layui-input layui-disabled" value="${_USER.jobNum}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">性别</label>
          <div class="layui-input-block">
            <select name="sex">
              <option value="0">保密</option>
              <option value="1" selected>男</option>
              <option value="2">女</option>
            </select>
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">生日</label>
          <div class="layui-input-block">
            <input id="birthday" name="birthday" lay-verType="tips" lay-verify="required"
                   value="${_USER.birthday?string("yyyy-MM-dd")}" class="layui-input">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">电话</label>
          <div class="layui-input-block">
            <input type="tel" name="tel" lay-verType="tips" lay-verify="phone" placeholder="请输入您的电话"
                   class="layui-input" maxlength="11" value="${_USER.tel}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">邮箱</label>
          <div class="layui-input-block">
            <input type="email" name="email" lay-verType="tips" lay-verify="email" placeholder="请输入您的邮箱"
                   class="layui-input" value="${_USER.email}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">所在学院</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.college.name!'默认学院'}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">所在部门</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.department.name!'默认部门'}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">现任职位</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.duty.name!'默认职位'}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">职位等级</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" name="dutyLevel" disabled>
          </div>
        </div>
      </div>

      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">入校日期</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.wtime?string("yyyy-MM-dd")}">
          </div>
        </div>
      </div>
      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">任职日期</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.ntime?string("yyyy-MM-dd")}">
          </div>
        </div>
      </div>

      <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
        <div class="layui-form-item">
          <label class="layui-form-label">用户角色</label>
          <div class="layui-input-block">
            <input class="layui-input layui-disabled" disabled value="${_USER.role.name}">
          </div>
        </div>
      </div>
      <div style="display: none;" id="settings-btn">
        <div class="layui-col-lg6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <label class="layui-form-label">验证码</label>
            <div class="layui-input-block" id="imgCode">
              <input placeholder="请输入验证码" name="code" class="layui-input" lay-verType="tips" lay-verify="required">
              <img src="${root}/verify">
            </div>
          </div>
        </div>

        <div class="layui-col-sm-offset6 layui-col-sm6 layui-col-xs12">
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn layui-btn-warm layui-btn-fluid" lay-submit>修 改</button>
            </div>
          </div>
        </div>
      </div>

      <div id="tog" class="text-right">
        <button type="button" class="layui-btn layui-btn-xs">我要修改</button>
      </div>
    </form>
  </div>
</div>
<script src="${root}/static/js/common.js"></script>
<script>
  layui.use(['form', 'jquery', 'layer', 'laydate'], function () {
    var form = layui.form;
    var $ = layui.$;
    var layer = layui.layer;
    var laydate = layui.laydate;

    form.on('submit', function (obj) {
      var field = obj.field;
      delete field.dutyLevel;

      $.post('${root}/user/change', field, function (data) {
        if (data.status === 200) {
          layer.msg('修改成功！', {icon: 6, time: 1200});
        } else {
          layer.alert('修改失败！', {title: '错误', icon: 5});
        }
      });
      return false;
    });

    form.val('setting-form', {
      sex: ${_USER.sex},
      dutyLevel: numToChinese(${_USER.dutyLevel!0}) + "级"
    });

    var stb = $('#settings-btn');
    $('#tog > button').click(function () {
      $(this).hide();
      stb.fadeToggle();
    });
    laydate.render({
      elem: '#birthday', //指定元素
      theme: '#3e8084'
    });
  });
</script>

<#include 'footer.ftl'>
